﻿/*
  +++++++++++++++++++++++++++++++++++++++++++
  +  Description: 字典类型表 管理
  +  Created by 王大宸 on 2020-10-05 23:28:38
  +  Created with IntelliJ IDEA.
  ++++++++++++++++++++++++++++++++++++++++++++
 */

var path = "/base/dict/type";
layui.use(['table', 'laypage'], function () {
    table = layui.table;
    layPage = layui.laypage;

    /* 初始化表格 */
    initTable();

    // 搜索
    $.searchTable.searchBtn();

    //监听行工具事件
    table.on('tool(baseDictTypeLay)', function (obj) {
        let data = obj.data;
        if ('del' === obj.event) {
            let removeUrl = path + '/' + data.id;
            $.http.remove(removeUrl, data.dictName);
        } else if ('edit' === obj.event) {
            let editUrl = path + '/edit/' + data.id;
            $.modal.open('修改', editUrl, '500', '350');
        } else if ('see' === obj.event) {
            location.href = homeUrl + '/base/dict/data/' + data.dictType + "/index";
        }
    });

});

/* 加载表格 */
function initTable() {
    let name = $("#name").val();
    $.table.init({
        url: path + "/page",
        where: {
            dictName: name
        },
        cols: [[
            {field: 'dictName', title: '字典名称', align: "center", width: 170},
            {field: 'dictType', title: '字典类型', align: "center", width: 170},
            {field: 'createUser', title: '创建者', align: "center", width: 120},
            {field: 'createTime', title: '创建时间', align: "center", width: 170},
            {field: 'updateUser', title: '更新者', align: "center", width: 120},
            {field: 'updateTime', title: '更新时间', align: "center", width: 170},
            {field: 'remark', title: '备注', align: "center"},
            {fixed: 'right', title: '操作', toolbar: '#toolbarHandle', width: 300, align: "center"}
        ]],
    });
}

/* 添加按钮 */
function saveBaseDictType() {
    let addUrl = path + '/add';
    $.modal.open("添加", addUrl, "500", "350");
}

